version 8.2
capture clear
capture log close
set more off
set mem 1000m
set mat 800



use "Enterprise surveys_judicial_reforms_for merge with standardized dataset.dta"

sort countryname year
*gen year_endline=year
*gen year_baseline2=year[_n-1] if countryname==countryname[_n-1]
*drop if year_baseline2==.

order countryname year_baseline2 year_endline2 reform_dum1 reform_dum_small1 reform_db_dum_big 
browse countryname year_endline2 year_baseline2 reform_dum1 reform_dum_small1 reform_db_dum_big reform_db_dum if dataset==1


count if reform_dum1==1

***Now merge with all judicial reforms for each country

sort countryname year
*only keep the post observation:
keep if countryname==countryname[_n-1]

keep countryname year_baseline2 year_endline2 reform_dum1 reform_dum_small1 reform_db_dum_big  reform_db_dum reform_budget_jud sueing_condition no_renegotiation_condition
*That is Table B2B3

append using "List_judicial_reforms.dta"
sort countryname reform_dum1 year iatiidentifier

ren year year_reform
drop reform_time_eligible

order countryname year_baseline2 year_endline2 year_reform iatiidentifier reportingorg	description	reform_access reform_speed reform_quality reform_dum1 reform_dum_small1 reform_budget_jud sueing_condition no_renegotiation_condition
browse countryname year_baseline2 year_endline2 year_reform iatiidentifier reportingorg	description	reform_access reform_speed reform_quality reform_dum1 reform_dum_small1 reform_budget_jud sueing_condition no_renegotiation_condition
 
*That is "List judicial reforms.xlsx" 

exit

